<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 300px;
            height: 30px;
            line-height: 30px;
            color: aqua;
            background-color: pink;
            margin-bottom: 30px;
        }
        p{
            width: 300px;
            height: 30px;
            line-height: 30px;
            color: aqua;
            background-color: pink;
            margin-bottom: 30px;
        }
    </style>
</head>

<body>
    <button>显示当前系统时间</button>
    <div>某个时间</div>
    <p>2</p>
    <script>
        //当我们点击了按钮里面的文字发生变化
        //1.获取元素
        var btn = document.querySelector('button');
        var div = document.querySelector('div');
        //2.事件源
        btn.onclick = function () {
            var date = new Date();
            div.innerText = date;
        }

        //我们元素可以不用添加事件
        var p = document.querySelector('p');
        var date = new Date();
        p.innerHTML = date;
    </script>
</body>

</html>